package com.zzhardy.example.firstExample;

import java.util.ArrayList;
import java.util.List;

import cn.zzhardy.utils.poi.ExcelCenter;
import cn.zzhardy.utils.result.AjaxResult;
import com.zzhardy.example.firstExample.model.Example;
import com.zzhardy.example.firstExample.model.SingleSheet;
import org.junit.Test;

/**
 * @Author：Hardy
 * @Date：2021/3/27
 * @Function:
 */
public class FirstExample {
    @Test
    public void excelTest() {
        List<Example> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Example example = new Example();
            example.setTitleOne("标题一 - " + i);
            example.setTitleTwo("标题二 - " + i);
            example.setTitleThree("标题三 - " + i);
            list.add(example);
        }
        ExcelCenter<Example> util = new ExcelCenter<>(Example.class);
        AjaxResult           form = util.exportExcel(list, "Excel生成案例");
        System.out.println(form.toString());
    }
    
    @Test
    public void excelSheetFieldTest() {
        List<Example> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Example example = new Example();
            example.setTitleOne("标题一  - " + i);
            example.setTitleTwo("标题二  - " + i);
            example.setTitleThree("标题三  - " + i);
            list.add(example);
        }
        SingleSheet singleSheet = new SingleSheet();
        singleSheet.setExampleList(list);
    
        ExcelCenter<SingleSheet> util = new ExcelCenter<>(SingleSheet.class);
        AjaxResult               form = util.exportExcel(singleSheet, "系统测试");
        System.out.println(form.toString());
    }
}
